#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/1/22 0:08
# @File     : kc16_03.py
# @Project  : jt808
def parse_03_heartbeat(body):
    # 解析0x0 充电桩心跳包
    data = {
        "桩编码": body[0:14],
        "枪号": body[14:16],
        "枪状态": parse_gun_status(int(body[16:18], 16)) + '(' + body[16:18] + ')',
        # 消息体为空
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


def parse_gun_status(result_value):
    results = ['正常', '故障']
    if 0 <= result_value < len(results):
        return results[result_value]
    else:
        return '未知枪状态'


__all__ = ['parse_03_heartbeat']
